home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000093_icon-group-sender _Sun Mar 23 15:59:28 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Sun, 23 Mar 1997 18:39:54 MST
  2. To: icon-group@cs.arizona.edu
  3. Date: Sun, 23 Mar 1997 15:59:28 +1000
  4. From: Stuart Robinson <Stuart.Robinson@anu.edu.au>
  5. Message-Id: <3334C6C0.3538@anu.edu.au>
  6. Sender: icon-group-request@cs.arizona.edu
  7. Subject: Problem with Another Program
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9. Status: RO
  10. Content-Length: 2429
  11.  
  12. Hello.  Marc Espie provided a solution to my last problem, for which I 
  13. am very thankful, but I have another problem which I was hoping 
  14. someone on comp.lang.icon could help me with.
  15.  
  16. A few weeks ago I posted a query to the newsgroup about a text 
  17. analysis program that I was trying to write.  Here is the original 
  18. posting.
  19.  
  20. >I have a number of texts each line of which has been coded for three types
  21. >of information.  Each line of the text will be assigned a number and a
  22. >code for two categories. The numbers are just whole numbers (raning from 1
  23. >to 20 or so) and each category has four members (say, ABCD and WXYZ). 
  24. >Here is an example text: 
  25. >
  26. >1 A X
  27. >1 A Y
  28. >1 B Y
  29. >2 B Y
  30. >
  31. >Note that some successive lines share an index number (as in lines 1 and
  32. >2 and 2 and 3).  When that is the case, I would like the program to
  33. >output the members of each category for the matched lines, as below:
  34. >
  35. >1-2    AA      XY
  36. >2-3    AB      YY
  37.  
  38. I received responses from Jan Theodore Galkowski/Helen Andrea 
  39. Galkowski,  Bob Alexander, and Todd A. Proebsting--each of whom I 
  40. would like to thank.  Todd Proebsting contributed the following 
  41. program:
  42.  
  43. procedure main()
  44.         count := 0
  45.         last_index := ""
  46.         last_cat1 := ""
  47.         last_cat2 := ""
  48.         while s := read() do {
  49.                 count +:= 1
  50.                 s ? {
  51.                         tab(upto(&digits++&letters))            # skip 
  52. initial non-letters/digits
  53.                         index := tab(many(&digits++&letters))   # get 
  54. letters/digits
  55.                         tab(upto(&digits++&letters))
  56.                         cat1 := tab(many(&digits++&letters))
  57.                         tab(upto(&digits++&letters))
  58.                         cat2 := tab(many(&digits++&letters))
  59.                 }
  60.                 if index == last_index then {
  61.                         write(count-1, "-", count, " ", last_cat1, 
  62. cat1, " ", last_cat2, cat2)
  63.                 }
  64.                 last_index := index;
  65.                 last_cat1 := cat1;
  66.                 last_cat2 := cat2;
  67.         }
  68. end
  69.  
  70. This program is great, but it keeps track of only one index number per 
  71. line.  However, the texts I will use the program to analyze contain 
  72. more than one index number per line.  (Unfortunately, I failed to make 
  73. this clear in my original posting.)  To highlight the problem, I will 
  74. provide an extract from a text (with inessential info ommitted):
  75.  
  76. {V.A 1{X
  77. {V.B    7{X    8{Y
  78. {V.B    7{X    8{Y
  79.